<?php


namespace app\common\model;

use app\common\service\redis\PoolRedis;
use app\model\AdminSchool;

class SchoolModel extends AdminSchool
{
    // 获取学校
    public static function getSchool($id)
    {
        $key = self::SCHOOL_CACHE_KEY.$id;
        $redis = PoolRedis::instance();
        $school = $redis->get($key);
        if ($school) {
            return $school;
        }
        $school = AdminSchool::where([
            'id' => $id,
            'is_delete' => 0
        ])->find();
        if ($school){
            $redis->set($key, $school);
        }
        return $school;
    }

}